import store from '@/store'
import config from '@/config'
import { isMobile } from '@/utils'

const switchEffectStrategies = {
  '1': function() {
    return 'BLEND(1.0, easeInCubic)'
  },
  '2': function() {
    return 'ZOOMBLEND(2.0, 2.0, easeInOutSine)'
  },
  '3': function() {
    return 'COLORBLEND(2.0, 0x000000, easeOutSine)'
  },
  '4': function() {
    return 'SLIDEBLEND(1.0, 0.0, 0.2, linear)'
  },
  '5': function() {
    return 'SLIDEBLEND(1.0, 90.0, 0.01, linear)'
  },
  '6': function() {
    return 'OPENBLEND(1.0, 0.0, 0.2, 0.0, linear)'
  },
  '7': function() {
    return null
  }
}

// 广告
export const visibleAd = () => {
  return visibleMenu('isad')
}

// 地址
export const visibleAddress = () => {
  return visibleMenu('isaddress')
}

//
export const visibleCompass = () => {
  return visibleMenu('iscompass')
}

// 是否显示天气
export const visibleWeather = () => {
  return visibleMenu('isweather')
}

// 是否显示作者
export const visibleAuthor = () => {
  return visibleMenu('hideuser')
}

// 打赏
export const visibleDs = () => {
  return visibleMenu('isds')
}

// 关注作品
export const visibleFollow = () => {
  return visibleMenu('isfollow')
}

// 加载动画
export const visibleLoading = () => {
  return visibleMenu('isloading')
}

// 场景是否显示
export const visibleScene = () => {
  return visibleMenu('isonsmallscene')
}

// 自动旋转
export const visibleAutoturn = () => {
  return visibleMenu('isonautoturn')
}

// 手机场景自动旋转
export const visibleMobileAutoturn = () => {
  return visibleMenu('isonmobileturn')
}

// 电脑场景自动切换
export const visiblePcAutoSwitch = () => {
  return visibleMenu('isonpcautoswitch')
}

// 人气
export const visiblePraise = () => {
  return visibleMenu('isonpraise')
}

// 点赞按钮
export const visibleFabulous = () => {
  return visibleMenu('isfabulous')
}

// 收藏按钮
export const visibleCollect = () => {
  return visibleMenu('iscollect')
}

// 旋转按钮
export const visibleRotate = () => {
  return visibleMenu('isrotate')
}

// 视角按钮
export const visibleVisualangle = () => {
  return visibleMenu('isvisualangle')
}

// 多屏互动按钮
export const visibleMultiscreen = () => {
  return visibleMenu('ismultiscreen')
}

// 密码访问
export const visiblePass = () => {
  return visibleMenu('ispass')
}

// 是否显示陀螺仪
export const visibleGyro = () => {
  return visibleMenu('showgyro')
}

// 陀螺仪是否默认开启
export const visibleGyroOn = () => {
  return visibleMenu('isongyro')
}

let isMobileInit = true
// 手机版背景音乐默认是否开启
export const visibleMobileMusic = () => {
  if (isMobileInit) {
    isMobileInit = false
    return visibleMenu('ismobilemusic')
  } else {
    return true
  }
}

let isPcInit = true
// 电脑版背景音乐默认是否开启
export const visiblePcMusic = () => {
  if (isPcInit) {
    isPcInit = false
    return visibleMenu('ispcmusic')
  } else {
    return true
  }
}

// 背景音乐是否循环播放
export const musicOnce = () => {
  return visibleMenu('ismusiconce')
}

// 场景音乐和背景音乐同时播放
export const musicMeanwhile = () => {
  return visibleMenu('musicmeanwhile')
}

// 说一说
export const visibleSay = () => {
  return visibleMenu('isonsay')
}

// VR
export const visibleVr = () => {
  return visibleMenu('showvr')
}

// 弹幕
export const visibleBarrage = () => {
  return visibleMenu('showbarrage')
}

// 分享
export const visibleShare = () => {
  return visibleMenu('showfx')
}

// 清屏
export const visibleClear = () => {
  return visibleMenu('showclear')
}

// 场景初始化是否显示
export const isSceneActive = () => {
  return visibleScene()
}

// 陀螺仪是否开启
export const isGyroActive = () => {
  return visibleGyro() && visibleGyroOn()
}

// 场景是否正在自动旋转
export const isSceneRotateActive = () => {
  return visibleAutoturn()
}


// 菜单图标是否显示
export const visibleMenu = (name) => {
  if(store.getters.panoInfo) {
    if (typeof(store.getters.panoInfo[name]) === 'boolean') {
      return store.getters.panoInfo[name]
    }
    return store.getters.panoInfo[name] == 1
  }
}

export const handleEffect = (type) => {
  return switchEffectStrategies[type]()
}

export const handlePerspective = (type) => {
  $VM.$krp.callScene(type)
}
